<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>我的订单 -潮玩商城</title>
    <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@500&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary: #FF6B9B;     /* Labubu主色调：粉色 */
            --secondary: #9A7DFF;   /* Labubu辅助色：紫色 */
            --accent: #FFD166;      /* Labubu强调色：黄色 */
            --bg-light: #FFF5F8;    /* Labubu浅色背景 */
            --text-dark: #5A5A5A;   /* Labubu深色文本 */
        }

        body {
            background-color: var(--bg-light);
            color: var(--text-dark);
            font-family: 'Segoe UI', sans-serif;
            margin: 0;
            padding: 20px;
        }
        h2 {
            color: var(--primary);
            text-shadow: 0 0 10px var(--primary);
            margin-bottom: 20px;
            font-family: 'Orbitron', sans-serif;
        }
        .navbar {
            padding: 15px;
            background: white;
            border-bottom: 2px solid var(--primary);
            margin-bottom: 20px;
            font-family: 'Orbitron', sans-serif;
        }
        .navbar a {
            color: var(--primary);
            margin-right: 20px;
            text-decoration: none;
            font-weight: bold;
            transition: color 0.3s, text-shadow 0.3s;
        }
        .navbar a:hover {
            color: var(--secondary);
            text-shadow: 0 0 5px var(--secondary);
        }
        table {
            width: 100%;
            border-collapse: collapse;
            background: white;
            box-shadow: 0 0 15px var(--primary);
            border-radius: 8px;
            overflow: hidden;
        }
        th, td {
            border: 1px solid var(--primary);
            padding: 12px 15px;
            text-align: center;
            font-size: 1rem;
        }
        th {
            background-color: white;
            font-family: 'Orbitron', sans-serif;
            font-weight: 700;
            letter-spacing: 1px;
            color: var(--secondary);
        }
        tbody tr:hover {
            background-color: var(--bg-light);
            cursor: pointer;
            transition: background-color 0.3s;
        }
        a.action-link {
            color: var(--primary);
            text-decoration: none;
            font-weight: bold;
            transition: color 0.3s, text-shadow 0.3s;
        }
        a.action-link:hover {
            color: var(--secondary);
            text-shadow: 0 0 8px var(--secondary);
        }
        @media screen and (max-width: 768px) {
            table {
                display: block;
                overflow-x: auto;
                white-space: nowrap;
            }
        }
    </style>
</head>
<body>

<div class="navbar">
    <c:choose>
        <c:when test="${sessionScope.loginUser != null}">
            欢迎您，${sessionScope.loginUser.uname}
            <a href="${pageContext.request.contextPath}/goods/frontList">商品首页</a>
            <a href="${pageContext.request.contextPath}/cart/list">购物车</a>
            <a href="${pageContext.request.contextPath}/order/myOrders">我的订单</a>
            <a href="${pageContext.request.contextPath}/user/logout" style="color: #ff6b6b;">退出登录</a>
        </c:when>
        <c:otherwise>
            <a href="${pageContext.request.contextPath}/login.jsp">登录</a>
            <a href="${pageContext.request.contextPath}/register.jsp">注册</a>
        </c:otherwise>
    </c:choose>
</div>

<h2>📦 我的订单</h2>

<table>
    <thead>
    <tr>
        <th>订单ID</th>
        <th>总金额</th>
        <th>状态</th>
        <th>创建时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="order" items="${orderList}">
        <tr>
            <td>${order.oid}</td>
            <td>￥${order.total}</td>
            <td>
                <c:choose>
                    <c:when test="${order.status == '待付款'}">
                        <span style="color: var(--primary); font-weight: bold;">待付款</span>
                    </c:when>
                    <c:when test="${order.status == '已付款'}">
                        <span style="color: var(--secondary); font-weight: bold;">已付款</span>
                    </c:when>
                    <c:when test="${order.status == '已发货'}">
                        <span style="color: #6B46C1; font-weight: bold;">已发货</span>
                    </c:when>
                    <c:when test="${order.status == '已完成'}">
                        <span style="color: #22C55E; font-weight: bold;">已完成</span>
                    </c:when>
                    <c:otherwise>未知状态</c:otherwise>
                </c:choose>
            </td>
            <td><fmt:formatDate value="${order.created}" pattern="yyyy-MM-dd" /></td>
            <td><a class="action-link" href="${pageContext.request.contextPath}/orderDetail/list/${order.oid}">查看详情</a></td>
        </tr>
    </c:forEach>
    <c:if test="${empty orderList}">
        <tr>
            <td colspan="5" style="color:#888;">暂无订单记录</td>
        </tr>
    </c:if>
    </tbody>
</table>

</body>
</html>